package org.bozo.im.service;


import android.util.Log;

public abstract class IMSession {

	public IMSession(IMSessionConfiguration pConfiguration) {}
	
	private boolean mIsStarted = false;
	
	public void login() {
		try {
			startSession();
		} catch (Exception e) {
			// ---------------------------------------------------------------------------------------
			Log.e(Constants.ACTIVITY_TAG, "org.bozo.im.service.IMSession.login ---------- Exception: ", e);
			// ---------------------------------------------------------------------------------------
		}
		mIsStarted = true;
	}
	
	public void logout() {
		try {
			stopSession();
		} catch (Exception e) {
			// ---------------------------------------------------------------------------------------
			Log.e(Constants.ACTIVITY_TAG, "org.bozo.im.service.IMSession.logout ---------- Exception: ", e);
			// ---------------------------------------------------------------------------------------
		}
		mIsStarted = false;
	}
	
	public boolean isStarted() {
		return mIsStarted;
	}
	
	public void setStarted(boolean pIsStarted) {
		mIsStarted = pIsStarted;
	}
	
	public abstract void startSession() throws Exception;
	public abstract void stopSession() throws Exception;
	public abstract IMSessionConfiguration getConfiguration();
}
